
enum FUN_LIST {
    //% block="X轴加速度"
     readFloatAccelX,
    //% block="Y轴加速度"
     readFloatAccelY,
    //% block="Z轴加速度"
     readFloatAccelZ,
    //% block="X轴角速度"
     readFloatGyroX,
    //% block="Y轴角速度"
     readFloatGyroY,
    //% block="Z轴角速度"
     readFloatGyroZ,
    //% block="温度（℃）"
     readTempC,
    //% block="温度（℉）"
     readTempF
}



//% color="#5ba55b" iconWidth=50 iconHeight=40
namespace LSM6DSM { 

    //% block="读取加速度陀螺仪传感器的 [FUN]" blockType="reporter"
    //% FUN.shadow="dropdown" FUN.options="FUN_LIST" 
     export function read_imu(parameter: any, block: any) {
        let fun = parameter.FUN.code;
        Generator.addInclude('#include_Wire_h>', '#include <Wire.h>');
        Generator.addInclude('#include_RL_LSM6DSM_h', '#include "RL_LSM6DSM.h"');
        Generator.addObject(`LSM6DSM_AccGyro`, `LSM6DSM `, `AccGyro;`);
        Generator.addSetup(`AccGyro_begin`, `AccGyro.begin(0x6B); `);
        Generator.addCode(`AccGyro.${fun}()`);
    }  
}
